﻿<%@ page language="java" import="com.newcrm.config.Const,com.newcrm.util.Util,com.newcrm.bean.*,java.util.List,java.util.Map" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
  User user = (User) session.getAttribute("user");
  Map<Integer, CompanyInfo> companys = (Map<Integer, CompanyInfo>) application.getAttribute(Const.APPLICATION_COMPANYS);
  CompanyInfo companyInfo = companys.get(Integer.valueOf(user.companyId));
  List<Map<String, Object>> dealCategory = companyInfo.dealCategorys;
  List<User> users = companyInfo.users;

  String dealStatus = (String) request.getAttribute("dealStatus");
  //自定义字段
  List<Map<String, Object>> fields = (List<Map<String, Object>>) request.getAttribute("fields");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>销售机会一览</title>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <meta name="renderer" content="webkit"/>
  <meta http-equiv="X-UA-Compatible" content="IE=Edge">
  <link rel="shortcut icon" href="<%=request.getContextPath()%>/images/qikebao.ico" />
  <link rel="stylesheet" href="<%=request.getContextPath()%>/css/all.css?ver=<%=Const.VERSION%>">
  <link rel="stylesheet" href="<%=request.getContextPath()%>/css/font-awesome/css/font-awesome.min.css">
  <link rel="stylesheet" href="<%=request.getContextPath()%>/css/datepicker.css" />
  <link rel="stylesheet" href="<%=request.getContextPath()%>/css/bootstrap-datetimepicker.min.css" />
  <link rel="stylesheet" href="<%=request.getContextPath()%>/css/magnific-popup.css">
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/jquery-1.11.1.min.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/bootstrap.min.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/jquery-ui.min.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/jquery.bootstrap-growl.min.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/moment.min.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/bootstrap-datepicker.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/bootstrap-datetimepicker.min.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/daterangepicker.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/jquery.magnific-popup.min.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/jquery.cookie.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/popbox.js"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/dealsSearch.js?ver=<%=Const.VERSION%>"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/pageNavi.js?ver=<%=Const.VERSION%>"></script>
  <script type="text/javascript" src="<%=request.getContextPath()%>/script/common.js?ver=<%=Const.VERSION%>"></script>
  <script>
    var _dealStatus = "<%=dealStatus%>";
    var pageSize = <%=Const.PAGE_SIZE%>;
    var allDealsCategory = new Array();
    <%if (dealCategory != null) {
        for (Map<String, Object> category:dealCategory) {
          String color = (String) category.get("Color");
          if (color == null || color.trim().length() == 0) {
            color = "000000";
          }
        %>
    allDealsCategory.push({id:"<%=category.get("DealCategoryId")%>",name:"<%=Util.UEncode((String)category.get("DealCategoryName"))%>", color:"<%=color%>"});
    <%  }
      } %>
    var allUsers = new Array();
    <%if (users != null) {
        for (User u:users) { %>
    allUsers.push({id:"<%=u.userId%>",name:"<%=Util.UEncode(u.name)%>",photo:"<%=u.imgPath%>"});
    <%  }} %>
    var field_type_text = "<%=Const.FIELD_TYPE_TEXT%>";
    var field_type_number = "<%=Const.FIELD_TYPE_NUMBER%>";
    var field_type_date = "<%=Const.FIELD_TYPE_DATE%>";
    var field_type_select = "<%=Const.FIELD_TYPE_SELECT%>";
    var field_type_checkbox = "<%=Const.FIELD_TYPE_CHECKBOX%>";
    var allDealFields = new Array();
   <%if (fields != null) {
        for (Map<String, Object> field:fields) {
        %>
    allDealFields.push({id:"<%=field.get("DealFieldId")%>",name:"<%=Util.UEncode((String)field.get("DealFieldName"))%>"});
    <%  }
      } %>
  </script>
</head>
<body class="parties">
  <jsp:include page="topNavi.jsp" flush="true"/>
  <div class="main-page">
    <table>
    <tr>
      <td class="main-body">
        <div class="topnavi">
          <div class='leftMenu'>
            <span>销售机会</span>
          </div>
          <div class="clearfix"></div>
        </div>
        <div class="switchTab" id="switchTab">
          <ul>
            <li id="switchTab_0" class="on"><a class="item" href="#" v="0">全部</a></li>
            <li id="switchTab_4"><a class="item" href="#" v="4">待审核</a></li>
            <li id="switchTab_1"><a class="item" href="#" v="1">跟踪中</a></li>
            <li id="switchTab_2"><a class="item" href="#" v="2">成功</a></li>
            <li id="switchTab_3" class="last"><a class="item" href="#" v="3">失败</a></li>
          </ul>
          <div class="searcharea">
            <input type="text" id="sidebar_live_search" name="term" class="searchinput" value="" title="输入名称，快速查找">
            <div class="searchinputicon"><span><a title="搜素" id="sidebar_live_search_link" href="#"><i class="fa fa-search"></i></a></span><span class="vline"> | </span> <span><a title="高级搜索" href="#" id="show-adv-search-link"><i class="fa fa-caret-down"></i></a></span></div>
          </div>
          <div class="clearfix"></div>
        </div>

        <jsp:include page="dealsSearchFilter.jsp" flush="true"/>
        <div id="deals_loading" class="loading">
          <div class="liner">
            <h3>销售机会加载中...</h3>
            <img alt="销售机会加载中..." src="<%=request.getContextPath()%>/images/dots-white.gif" />
          </div>
        </div>
        <div id="deals_none" class="loading" style="display:none;">
          <div class="liner">
            <h3>没有符合条件的销售机会</h3>
          </div>
        </div>
        <div class="searchresult" id="searchresult">
          <table class="deals" id="confirm_deals" style="display:none;">
            <tr>
              <th colspan="3" class="confirm">
                <h2>待审核的销售机会</h2>
              </th>
            </tr>
          </table>
          <table class="deals" id="pending_deals" style="display:none;">
            <tr>
              <th colspan="3" class="pending">
                <h2>跟踪中的销售机会</h2>
              </th>
            </tr>
          </table>
          <table class="deals" id="won_deals" style="display:none;">
            <tr>
              <th colspan="3" class="won">
                <h2>已经成功的销售机会<span> &mdash; <span id="totalWonNum"></span> 笔  合计 <span id="totalMoney"></span> 元 / 提成 <span id="totalCommission"></span> 元</span></h2>
              </th>
            </tr>
          </table>
          <table class="deals" id="lost_deals" style="display:none;">
            <tr>
              <th colspan="3" class="lost">
                <h2>失败的销售机会</h2>
              </th>
            </tr>
          </table>
          <div class="pagination"><div class="page-bottom" id="pageNavi"></div></div>
        </div>
      </td>
      <td class="main-sidebar">
        <div class="content">
          <h2 class="clearfix">创建销售机会</h2>
          <div class="detail">
            <a href="<%=request.getContextPath()%>/deals/new" class="button green"><i class="fa fa-rmb"></i> 创建销售机会</a>
          </div>
          <% if (user.isCanExport()) {%>
          <h2 class="clearfix">导出销售机会</h2>
          <div class="detail"><a href="#" id="exportDeals">导出</a> 销售机会</div>
          <%}%>
        </div>
      </td>
    </tr>
    </table>
  </div>
</body>
</html>